package com.gaia.member.gaiatt.mygaia;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.gaia.member.gaiatt.R;
import com.gaia.member.gaiatt.bean.MyOrderServiceBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by zhangHaiTao on 2016/5/7.
 */
public class MyOrderServiceFragment extends Fragment {
    @Bind(R.id.lv_my_order_service)
    ListView lvMyOrderService;

    private List<MyOrderServiceBean> myOrderServiceList = new ArrayList<>();
    private MyOrderSeviceAdapter myOrderSeviceAdapter;
    private Context mContext;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mContext = getActivity();
        View view = inflater.inflate(R.layout.fragment_mygaia_my_order_service, null);
        ButterKnife.bind(this, view);

        for (int i=0; i<10; i++) {
            MyOrderServiceBean serviceBean = new MyOrderServiceBean();
            myOrderServiceList.add(serviceBean);
        }
        lvMyOrderService.setAdapter(new MyOrderSeviceAdapter(mContext,0,  myOrderServiceList));
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    class MyOrderSeviceAdapter extends ArrayAdapter<MyOrderServiceBean> {

        List<MyOrderServiceBean> myOrderServiceList;
        Context mContext;
        public MyOrderSeviceAdapter(Context context, int resource, List<MyOrderServiceBean> objects) {
            super(context, resource, objects);
            myOrderServiceList = objects;
            mContext = context;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(mContext, R.layout.item_list_mygaia_my_order_service, null);
            }
            return convertView;
        }
    }
}
